#ifndef __MYTEST_H__
#define __MYTEST_H__

#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <time.h>

#define RAND_INIT srand((unsigned int)time(NULL));
#define RAND(st,ed) (rand() % ((ed) - (st)) + (st))//from st to ed - 1

#define ASNI_BOLD      "\33[1;1m"
#define ASNI_FG_BLACK   "\33[1;30m"
#define ASNI_FG_RED     "\33[1;31m"
#define ASNI_FG_GREEN   "\33[1;32m"
#define ASNI_FG_YELLOW  "\33[1;33m"
#define ASNI_FG_BLUE    "\33[1;34m"
#define ASNI_FG_MAGENTA "\33[1;35m"
#define ASNI_FG_CYAN    "\33[1;36m"
#define ASNI_FG_WHITE   "\33[1;37m"
#define ASNI_BG_BLACK   "\33[1;40m"
#define ASNI_BG_RED     "\33[1;41m"
#define ASNI_BG_GREEN   "\33[1;42m"
#define ASNI_BG_YELLOW  "\33[1;43m"
#define ASNI_BG_BLUE    "\33[1;44m"
#define ASNI_BG_MAGENTA "\33[1;35m"
#define ASNI_BG_CYAN    "\33[1;46m"
#define ASNI_BG_WHITE   "\33[1;47m"
#define ASNI_NONE       "\33[0m"

#define ASNI_FMT(str, fmt) fmt str ASNI_NONE
#define TURN_YELLOW(str) ASNI_FMT(str, ASNI_FG_YELLOW)
#define TURN_RED(str) ASNI_FMT(str, ASNI_FG_RED)
#define TURN_GREEN(str) ASNI_FMT(str, ASNI_FG_GREEN)
#define TURN_BLUE(str) ASNI_FMT(str, ASNI_FG_BLUE)

#define T_Y(str) TURN_YELLOW(str)
#define T_R(str) TURN_RED(str)
#define T_G(str) TURN_GREEN(str)
#define T_B(str) TURN_BLUE(str)

/*generate test string*/
static inline void generate_one_string(char *buf)
{
    int len = RAND(0,20);
    for(int i = 0; i < len; i++)
    {
        buf[i] = RAND(0,24) + 'a';
    }
}

#endif
